<?php

namespace App\Console\Commands;

use App\Models\AuthenticLog;
use App\Models\Category;
use App\Models\Goods;
use App\Models\GoodsSetmeal;
use App\Models\Logistics;
use App\Models\MemberOther;
use App\Models\Order;
use App\Models\OrderGoods;
use App\Models\OrderLease;
use App\Models\Risk;
use App\Models\ShopUser;
use App\Models\ZlbInsurance;
use App\Models\ZlbLogistics;
use App\Services\OrderService;
use App\Services\ZlbService;

class ZlbV1Command extends BaseCommand
{
    protected static $zlbService;
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'zlbV1';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '新版租赁宝';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        self::$zlbService = new ZlbService();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    protected function handleExec()
    {
        try {
            if(true){
                // $notary_task = ZlbNotoryTask::where(['status'=>0])->limit(10)->get();
                // $notary_task = ZlbNotoryTask::where(['status'=>0])->get();
                // $notary_task =  obToArray($notary_task);
                $notary_task = array(
                    array(
                        // 'ids'=>['20220930162246135554'],
                        'ids'=>['835'],
                        // 'type'=>'goods',
                        // 'type'=>'deliver'
                        // 'type'=>'confirm',
                        'type'=>'rental',
                        'params'=>'1'
                    )

                );
                if($notary_task){
                    foreach ($notary_task as $item){
                        $ids = $item['ids'];
                        if($ids){
                            // dd($item['type']);
                            foreach ($ids as $id){
                                //商品上链
                                if($item['type'] == ZlbService::TYPE_GOODS){
                                    $this->leaseProduct($id);
                                    continue;
                                }
                                //发货上全部链
                                if($item['type'] == ZlbService::TYPE_DELIVER){
                                    // dd($id);
                                    $this->leaseUser($id);
                                }
                                //确认收货
                                if($item['type'] == ZlbService::TYPE_CONFIRM){
                                    // dd($id);
                                    $this->leaseLogisticConfirm($id);
                                }
                                //正常账单履约
                                // dd(ZlbService::TYPE_RENTAL);
                                if($item['type'] == ZlbService::TYPE_RENTAL){
                                    // dd($id);
                                    $this->leaseRental($id,$item['params']);
                                }
                                //订单上保险
                                if($item['type'] == ZlbService::TYPE_INSURANCE){
                                    $this->insuranceCreateNew($id);
                                }
                                //订单退保险
                                if($item['type'] == ZlbService::TYPE_INSURANCE_REFUND){
                                    $this->insuranceRefundNew($id);
                                }
                            }
                            // ZlbNotoryTask::where(['id'=>$item['id'] ])->update(['status'=>1]);
                        }
                    }
                    $this->infoLog('新版租赁宝执行成功',$notary_task);
                }
            }else{
                $this->infoLog('新版租赁宝未开启执行开关');
            }
        }catch (\Exception $exception){
            $this->infoLog('上链错误'.$exception->getMessage());
        }
    }

    /**
     * 租赁宝存证⽂件哈希-需存证
     * @param $filePath
     * @return bool|mixed
     */
    public static function fileHash($filePath)
    {
        $request = [
            'hash'=>$filePath,
        ];
        return self::$zlbService->fileApi($request);
    }

    /**
     * 商品信息
     * @param $orderId
     */
    public function leaseProduct($orderId)
    {
        $orderGoods = obToArray(OrderGoods::where(['order_id'=>$orderId])->select('goods_id','pact_type','setmeal_id','setmeal_title','goods_id','goods_title','device_number')->first());
        // dd($orderGoods);
        $goods = obToArray(Goods::where(['id'=>$orderGoods['goods_id']])->first());

        $shopname = ShopUser::where(['member_id'=>$goods['member_id']])->value('shopname');
        $zlb_class= Category::where(['id'=>$goods['category_id']])->value('zlb_class');
        // var_dump($orderGoods);
        // $goodsSetmeal = obToArray(GoodsSetmeal::where(['id'=>$orderGoods['setmeal_id']])->first());
        $goodsSetmeal = obToArray(GoodsSetmeal::where(['title'=>$orderGoods['setmeal_title'],'goods_id'=>$orderGoods['goods_id']])->first());
        // dd($goodsSetmeal);
        $version = md5($goods['id'].rand(10000, 99999).$goodsSetmeal['id']);
        $request = [
            "productModel" => mb_strlen($goodsSetmeal['title'],"utf-8") > 30 ? mb_substr($goodsSetmeal['title'],0,30) : $goodsSetmeal['title'],//商品规格
            "productId" => $orderGoods['goods_id'],//商品编码
            "categoryCass" => $zlb_class,//租赁宝⼆级⾏业
            "productDetailInfo" => $orderGoods['goods_title'],//商品详情
            "productBrand" => mb_strlen($shopname,"utf-8") > 30 ? mb_substr($shopname,0,30) : $shopname,//商品品牌
            "productName" => mb_strlen($orderGoods['goods_title'],"utf-8") > 50 ? mb_substr($orderGoods['goods_title'],0,50) : $orderGoods['goods_title'],//商品名称
            "productVersion" => $version,
            "realStock" => $goodsSetmeal['quantity'],//实际库存量
            "estimatedShipment" => $goodsSetmeal['quantity'],//预估出货量
            "productUrl" => config('alipay.oss.imgHost') . $goods['imgurl'],//商品链接
            "productPrice" => $goodsSetmeal['price'],//商品价格(租金，不包含买断金) 元
            "depositPrice" => $goodsSetmeal['foregift'],//免押⾦额 元
        ];
        //添加记录
        // ZlbGoods::add($orderId,$goods,$shopname,$zlb_class,$goodsSetmeal,$version);
        $notary = self::$zlbService->productApi($request);
        // dd($notary);
        //更新记录
        // ZlbGoods::set($orderId,$request,$notary);
    }

    /**
     * 订单用户信息-有返回值-需存证
     * @param $orderNo
     */
    public function leaseUser($orderNo)
    {
        $order = Order::from('sp_order_2 as o')
            ->leftjoin('sp_member_2 as m','o.uid','=','m.id')
            ->select('o.*','m.cert_no')
            ->where(['o.trade_no'=>$orderNo,'o.sign_status'=>2])
            // ->whereIn("o.status",OrderService::getOrderStatus(OrderService::ZLB_ORDER_STATUS))
            ->first();
        $order = obToArray($order);
        // dd($order);
        if($order){
            //检测商品是否上链
            // $goods = obToArray(ZlbGoods::where(['order_id'=>$order['id']])->first());
            // var_dump($goods);
            // if(empty($goods)){
                $this->leaseProduct($order['id']);
            // }
            // var_dump($order);
            $authentic = AuthenticLog::where(['cert_no'=>$order['cert_no'],'status'=>AuthenticLog::AUTHENTIC_STATUS_PASS])->first();
            $authentic = obToArray($authentic);
            // var_dump($authentic);
            $member = MemberOther::where(['id'=>$order['uid']])->first()->toArray();
            $risk = Risk::where(['order_id'=>$order['id']])->select('model_details_score')->first();
            $risk = obToArray($risk);
            $filePath = config('alipay.oss.imgHost') . $authentic['idcard_front'];
            // dd($filePath);
            //先文件存证
            $hash = hash_file('sha256', $filePath);
            self::fileHash($hash);
            $request = [
                "loginId" => $member['user_id'],// 支付宝登录名或者user_id
                "orderId" => $orderNo,//平台订单号
                "userIdCard" => $authentic['cert_no'],//承租人身份证号码
                "userImageHash" => $hash,//承租⼈身份证照⽚正⾯哈希
                "userName" => $authentic['cert_name'],//承租人姓名
                "userPhone" => $member['mobile'],//承租人电话
                "userImageUrl" => $filePath,//租赁⼈身份证照⽚正⾯地址【租赁 机构⾃⾏加密】
                "certifyId" => $authentic['certify_id'],//区块链认证Hash，若为支付宝实人，必填
                "loginTime" => dateFormat(time()),//登录时间
            ];
            //添加记录
            // ZlbAuthentic::add($order,$member,$authentic,$risk,$hash);
            $notary = self::$zlbService->userApi($request);
            // dd($notary);
            //更新记录
            // ZlbAuthentic::set($order,$request,$notary);
            //订单上链
            $this->leaseOrder($order,$risk);
        }
    }

    /**
     * 订单信息-有返回值-需存证
     * @param $order
     */
    public function leaseOrder($order,$risk)
    {
        // dd(1);
        $filePath = config('alipay.oss.imgHost') . $order['pact_url'];
        // dd($filePath);
        $hash = hash_file('sha256', $filePath);
        //先文件存证
        self::fileHash($hash);
        $lease = OrderLease::where(['order_id'=>$order['id']])->orderBy('id','asc')->first();
        $lease = obToArray($lease);
        // dd($lease);
        if($lease){
            $orderGoods = OrderGoods::where(['order_id'=>$order['id']])->select('pact_type','setmeal_id','goods_id','goods_title','device_number','setmeal_price','website_price')->first()->toArray();
            $price = sprintf("%.2f", $order['amount']*$orderGoods['website_price']);
            //0:随租随还,1:固定租期
            $buyMoney = sprintf("%.2f", $order['amount']*$orderGoods['setmeal_price']);
            $request = [
                "orderPayType" => $lease['pay_type'] == OrderLease::LEASE_PAY_TYPE_ZM ? 1 : 3,//订单⽀付类型 1 预授权，2信⽤套餐，3⽀付宝代扣，4其他
                "orderCreditRent" => !empty($order['foregift_deduct']) ? $order['foregift_deduct'] : 0,//免押金额 元
                "creditAmount" => !empty($order['foregift']) ? $order['foregift'] : 0,//芝麻信用免押金额 实际预授权⾦额，芝麻 信⽤免押⾦额 元
                "buyMoney" => $buyMoney,//到期买断价 元
                "orderTotalRent" => $order['rent_total'],//租⾦总额 元
                "monthAmount" =>  sprintf("%.2f", ($order['rent_total']/$order['month_total'])),//月租金 元
                "contentHash" => $hash,//融资租赁及服务协议文件hash，三方协议
                "leaseContractUrl" => $filePath,//租赁合同地址
                "orderCreateTime" => dateFormat($order['create_time']),//订单创建时间 格式为2019-8-31 12:00:00
                "orderId" => $order['trade_no'],//订单id 长度不可超过50
                "orderStagesId" => $lease['id'],//⽀付订单ID
                "payTime" => dateFormat($lease['pay_time']),//订单支付时间 格式为2019-8-31 12:00:00
                "monthTotal" => $order['month_total'],//租期/月
                "yidunScore" => isset($risk['model_details_score']) ? $risk['model_details_score'] : 0,//蚁盾分数
                "province" => $order['prov'],//省
                "city" => $order['city'],//市
                "area" => $order['area'],//区
                "userAddress" => $order['prov'].$order['city'].$order['area'].$order['address'],//承租人收货地址
            ];
            //添加记录
            // ZlbOrder::add($order,$lease,$buyMoney,$request,$orderGoods,$hash);
            $notary = self::$zlbService->orderApi($request);
            // dd($notary);
            //更新记录
            // ZlbOrder::set($order,$request,$notary);
            //订单商品上链
            $this->leaseOrderProduct($order,$orderGoods,$price);
        }
    }

    /**
     * 订单商品信息-有返回值
     * @param $order
     * @param $orderGoods
     */
    public function leaseOrderProduct($order,$orderGoods,$price)
    {
        // dd(1);
        // $goods =  obToArray(ZlbGoods::where(['order_id'=>$order['id']])->first());
        $request = [
            'productId' => $orderGoods['goods_id'],//商品编码，与融资租赁 公司约定的产品Id，⻓ 度不超过50
            'productName' => $orderGoods['goods_title'],//产品名称，⻓ 度不超过50
            "orderId" => $order['trade_no'],//订单id ⻓度不可超过 50
            "productVersion" => 'HHH123',//商品版本
            "serialNumber" => $orderGoods['device_number'] ? $orderGoods['device_number'] : 'HHH123',//供应商对应的产品唯⼀ 标识码
            "productPrice" => $price,//商品价格
            "number" => $order['amount'],//产品数量
        ];
        // ZlbOrderGoods::add($order,$orderGoods,$goods,$price);
        $notary = self::$zlbService->orderProductApi($request);
        //更新记录
        // ZlbOrderGoods::set($order,$request,$notary);
        //发货上链
        // dd($notary);
        $this->leaseLogisticDeliver($order);
        // $this->leasePromise($order);
    }

    /**
     * 物流信息-发货-有返回值-需存证
     * @param $order
     */
    public function leaseLogisticDeliver($order)
    {
        // dd(1);
        $logic = Logistics::where(['order_id'=>$order['id'],'type'=>Logistics::EXPRESS_TYPE_SEND])->first();
        $logic = obToArray($logic);
        if($logic){
            $filePath = 'https://api.qianbaozuji.com/logisticsH5?orderNo='.$order['trade_no'];
            // dd($filePath);
            //先文件存证
            $hash = hash_file('sha256', $filePath);
            self::fileHash($hash);
            if($logic['delivery_type'] != Logistics::ORDER_DELIVERY_TYPE_EXPRESS){
                $logic['logistics_name'] = Logistics::DELIVERY_TYPE[$logic['delivery_type']];
                $logic['logistics_no'] = date("YmdHis");
            }
            $request = [
                "logisticCompanyName" => $logic['logistics_name'],//物流公司简称
                "logisticsOrderId" => $logic['logistics_no'],//物流订单id
                "deliverTime" => dateFormat($logic['create_time']),//物流发货时间,格式为 2019-8-31 12:00:00
                "orderId" => $order['trade_no'],//订单id ⻓度不可超过 50
                "arriveConfirmHash" => $hash,//存证
                "arriveConfirmUrl" => $filePath,//签收记录URL，已签收需要必须
            ];
            //添加记录
            // ZlbLogistics::addDeliver($order,$logic,$filePath);
            $notary = self::$zlbService->logisticDeliverApi($request);
            // dd($notary);
            //更新记录
            // ZlbLogistics::updateDeliver($order,$request,$notary);
        }
        // dd($order);
        //承诺上链
        $this->leasePromise($order);
    }
    /**
     * 租赁订单承诺信息 -有返回值-只调取一次
     * @param $order
     */
    public function leasePromise($order)
    {
        // dd(123);
        $lease = OrderLease::where(['order_id'=>$order['id']])->orderBy('which_period','asc')->get();
        $lease = obToArray($lease);
        if($lease){
            $payMoneyList = [];
            $payDateList = [];
            $payLeaseId = [];
            foreach ($lease as $v){
                $payDateList[] = dateFormat($v['begin_time']);
                $payMoneyList[] = toHao($v['rent']);
                if($v['status'] == OrderLease::ORDER_LEASE_STATUS_PAID){
                    $payLeaseId[] = $v['id'];
                }
            }
            $request = [
                "orderId" => $order['trade_no'],//订单id，长度不可超过50
                "payPeriod" => $order['month_total'],//总租期
                "payMoneyList" => $payMoneyList,//应付租⾦，精确到毫 厘，即123400表示 12.34元
                "payDateList" => $payDateList//应付租⾦时间，格式为 2019-8-31 12:00:00
            ];
            // ZlbOrderLease::leasePromiseAdd($order,$lease);
            $notary = self::$zlbService->leasePromiseApi($request);
            // dd($notary);
            //更新记录
            // ZlbOrder::promiseSet($order,$request,$notary);
            //履约上链
            if($payLeaseId){
                foreach ($payLeaseId as $leaseId){
                    $this->leaseRental($leaseId);
                }
            }
        }
    }

    /**
     * 租赁订单履约信息 -有返回值-
     * @param $leaseId
     * @param int $type
     */
    public function leaseRental($leaseId,$type=ZlbService::LEASE_RENT_STATUS_YES)
    {
        // dd($leaseId);
        if($type == ZlbService::LEASE_RENT_STATUS_END){
            $lease = OrderLease::where(['id'=>$leaseId])->orderBy('which_period','asc')->first();
        }else{
            $lease = OrderLease::where(['id'=>$leaseId,'status'=>OrderLease::ORDER_LEASE_STATUS_PAID])->orderBy('which_period','asc')->first();
        }

        $lease = obToArray($lease);
        // $arr = [];
        // if(empty($lease)){
        //   $arr[] = $leaseId;
        // }
        // var_dump($lease);
        if($lease){
            $order = Order::where(['id'=>$lease['order_id']])->select('trade_no','month_total')->first()->toArray();
            if($lease['pay_type'] == OrderLease::LEASE_PAY_TYPE_ANTCHAIN){
                $pay_type = 2;
            }elseif ($lease['pay_type'] == OrderLease::LEASE_PAY_TYPE_ZM){
                $pay_type = 1;
            }else{
                $pay_type = 3;
            }
            $rand_no = 'TXZ'.date('YmdHis').mt_rand(1000,9999).mt_rand(1000,9999);

            OrderLease::where(['id'=>$leaseId])->update(array('trade_no'=>$rand_no));

            $trade_no = !empty($lease['trade_no'])?$lease['trade_no']:$rand_no;
            $request = [
                "rentalReturnState"=>$type?$type: 1,//租金归还状态，1足额归还，2部分归还，3未归还，4退租，5该订单整个生命周期已完结
                "orderId" => $order['trade_no'],//订单id，长度不可超过50
                "rentalMoney" => $type==5?0:$lease['rent'],//租金归还金额，精确到毫厘，即123400表示，12.34元
                "returnVoucherType"=>$type==5?3:1,//还款凭证类型，1支付宝，2平台代收(客户主动还款)，3其他
                "remainTerm" => $order['month_total'] - $lease['which_period'],//剩余归还期数
                "returnTime" => dateFormat($lease['pay_time']),//归还时间，格式为”2019-07-31 12:00:00’
                "returnVoucherSerial" => $type==5?'完结':$trade_no,//是	还款凭证编号，不超过128字符，1支付宝流水号
                "returnWay"=>$type==5?4:$pay_type,//归还方式，1预授权代扣，2支付宝代扣，3主动还款，4其他
                "leaseTermIndex" => $lease['which_period']//租期编号
            ];
            // dd($request);
            // ZlbOrderLease::leaseAdd($order['trade_no'],$lease,$type);
            $notary = self::$zlbService->rentalApi($request);
            dd($notary);
            //更新记录
            // ZlbOrderLease::leaseUpdate($order['trade_no'],$lease,$request,$notary);
        }
    }

    /**
     * 物流信息-签收-有返回值-需存证
     * @param $order
     */
    public function leaseLogisticConfirm($orderNo)
    {
        $order = Order::from('sp_order_2 as o')
                ->leftjoin('sp_order_goods_2 as og','og.order_id','o.id')
                ->leftjoin('sp_goods_2 as g','og.goods_id','g.id')
                ->select('o.*','og.goods_id','g.rent_label','g.pact_type')
                ->where(['o.trade_no'=>$orderNo,'o.sign_status'=>2])
                ->first();
        $order = obToArray($order);

        // dd($order);
        if($order){
            $logic = Logistics::where(['order_id'=>$order['id'],'status'=>Logistics::EXPRESS_STATUS_SIGNED])->first();
            $logic = obToArray($logic);
            // dd($logic);
            if($logic){
                $filePath = 'https://api.qianbaozuji.com/logisticsH5?orderNo='.$orderNo;
                $hash = hash_file('sha256', $filePath);
                // dd($hash);
                //先文件存证
                self::fileHash($hash);
                if($logic['delivery_type'] != Logistics::ORDER_DELIVERY_TYPE_EXPRESS){
                    $logic['logistics_name'] = Logistics::DELIVERY_TYPE[$logic['delivery_type']];
                    $logic['logistics_no'] = ZlbLogistics::where(['order_no'=>$order['trade_no']])->value('logistics_no');
                }
                // dd(1);
                $request = [
                    "logisticCompanyName" => $logic['logistics_name'],//物流公司简称
                    "logisticsOrderId" => $logic['logistics_no']?$logic['logistics_no']:1,//物流订单id
                    "deliverTime" => dateFormat($logic['create_time']),//物流发货时间,格式为 2019-8-31 12:00:00
                    "orderId" => $orderNo,//订单id ⻓度不可超过 50
                    "arriveConfirmHash" => $hash,//存证
                    "arriveConfirmTime" => dateFormat($logic['confirm_time']),//⽤户签收时间，格式为 2019-8-31 12:00:00，已签收需要必填
                    "arriveConfirmUrl" => $filePath,//签收记录URL，已签收需要必须
                    "extraInfo"=>$logic['info'] ? $logic['info'] : json_encode([])//资⽅定义的其他额外字段，以json形式传递-物流信息
                ];
                //添加记录
                // ZlbLogistics::addConfirm($order,$logic,$filePath);
                $notary = self::$zlbService->logisticConfirmApi($request);
                // dd($notary);
                //更新记录
                ZlbLogistics::updateConfirm($order,$request,$notary);

                //确认收货上链后购买保险
                //条件  1、上传商品选择了开启保险 2、租完归还买断
                if(strstr($order['rent_label'],'保险') && strstr($order['pact_type'],'1')){
                    $shop = ShopUser::where(['member_id'=>$order['seller_id']])->select('companyid','company_area','company','mechanism','email','mobile')->first();
                    if($shop){
                        $requestData = [
                            'orderNo'=>$orderNo,
                            "insured"=>[
                                "insuredIdNo"=>$shop['companyid'],
                                "insuredName"=>$shop['mechanism'],
                                "insuredMobile"=>$shop['mobile'],
                                "insuredAddress"=>$shop['company_area'].$shop['company'],
                                "insuredMail"=>$shop['email'],
                            ],
                        ];
                        $result = self::$zlbService->insuranceCreateApi($requestData);
                        //添加记录
                        ZlbInsurance::insuranceAdd($orderNo,$result,$order['seller_id']);
                        if(isset($result['result_msg']) && $result['result_msg'] == 'success' && $result['code'] == 0 && $result['result_code'] == 200 && isset($result['response_data'])){
                            $this->infoLog('订单购买保险执行成功',$result);
                        }else{
                            $this->infoLog('订单购买保险执行失败',$result);
                        }
                    }
                }else{
                    $this->infoLog('订单不符合购买保险条件',[$orderNo]);
                }




            }
        }

    }

    /**
     * 上保险--在用
     * @param $orderNo
     */
    public function insuranceCreateNew($orderNo){
        $order = Order::where(['trade_no'=>$orderNo,'sign_status'=>2])
            ->whereIn("status",OrderService::getOrderStatus(OrderService::ZLB_ORDER_STATUS))
            ->first();
        $order = obToArray($order);
        if($order){
            $shop = ShopUser::where(['member_id'=>$order['seller_id']])->select('companyid','company_area','company','mechanism','email','mobile')->first();
            if($shop){
                $request = [
                    'orderNo'=>$orderNo,
                    "insured"=>[
                        "insuredIdNo"=>$shop['companyid'],
                        "insuredName"=>$shop['mechanism'],
                        "insuredMobile"=>$shop['mobile'],
                        "insuredAddress"=>$shop['company_area'].$shop['company'],
                        "insuredMail"=>$shop['email'],
                    ],
                ];
                $notary = self::$zlbService->insuranceCreateApi($request);
                //添加记录
                ZlbInsurance::insuranceAdd($orderNo,$notary);
            }
        }
    }

    /**
     * 退保
     */
    public function insuranceRefundNew($orderNo){
        $order = Order::where(['trade_no'=>$orderNo,'sign_status'=>2])
            ->whereIn("status",OrderService::getOrderStatus(OrderService::ZLB_ORDER_STATUS))
            ->first();
        $order = obToArray($order);
        if($order){
            $companyid = ShopUser::where(['member_id'=>$order['seller_id']])->value('companyid');
            if($companyid){
                $request = [
                    'orderId'=>$orderNo,
                    'insuredIdNo'=>$companyid,
                ];
                $notary = self::$zlbService->insuranceRefundApi($request);
                //添加记录
                ZlbInsurance::insuranceRefundAdd($orderNo,$notary);
            }
        }
    }

    /**
     * 投保查询
     * @param $orderNo
     * @param bool $addFlag
     */
    public function insuranceQueryNew($orderNo,$addFlag=true){
        $order = Order::where(['trade_no'=>$orderNo,'sign_status'=>2])
            ->whereIn("status",OrderService::getOrderStatus(OrderService::ZLB_ORDER_STATUS))
            ->first();
        $order = obToArray($order);
        if($order){
            $request = [
                'orderId'=>$orderNo,
            ];
            $notary = self::$zlbService->insuranceQueryApi($request);
            if($addFlag){
                ZlbInsurance::insuranceAdd($orderNo,$notary);
            }else{
                ZlbService::requestLog('租赁宝投保信息查询',$request,$notary);
            }

        }
    }

}
